﻿@using Covenant.Models
@using Covenant.Models.Covenant
@using Microsoft.AspNetCore.Identity
@model CovenantUserLogin
@{
    Layout = "_CovenantUserLayout";
    ViewData["Title"] = "CovenantUsers";
    IEnumerable<string> RolesSelected = ViewBag.RolesSelected;
    IEnumerable<string> RolesNotSelected = ViewBag.RolesNotSelected;
}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3">
    <h1 class="h2">User: <span id="user-name" class="text-primary">@Html.DisplayFor(model => model.UserName)</span></h1>
</div>

<div class="row">
    <div class="col-md border-right">
        <form asp-action="Edit">
            <div asp-validation-summary="All"></div>
            <div class="form-group">
                <label asp-for="UserName"></label>
                <input asp-for="UserName" value="@Model.UserName" class="form-control" readonly>
            </div>
            <div class="form-group">
                <label asp-for="Password"></label>
                <input type="password" asp-for="Password" value="@Model.Password" class="form-control">
            </div>
            <button type="submit" class="btn btn-primary"><span data-feather="edit"></span> Change Password</button>
        </form>
    </div>
    <div class="col-md">
        <form asp-action="EditRoles">
            <div asp-validation-summary="All"></div>
            <div class="form-group">
                <input name="UserName" value="@Model.UserName" type="hidden">
                <label for="set-roles">Edit Roles</label><br />
                <select name="Rolenames" id="set-roles" class="selectpicker show-menu-arrow" multiple data-dropup-auto="false" data-width="auto" data-live-search="true" data-selected-text-format="count > 2">
                    @foreach (var role in RolesSelected)
                    {
                        <option selected>@role</option>
                    }
                    @foreach (var role in RolesNotSelected)
                    {
                        <option>@role</option>
                    }
                </select>
            </div>
            <button type="submit" class="btn btn-primary"><span data-feather="edit"></span> Edit Roles</button>
        </form>
    </div>
</div>
<form asp-action="Delete" asp-route-id="@Model.Id">
    <button type="submit" class="btn btn-danger mt-2"><span data-feather="x"></span> Delete</button>
</form>